<template>
  <div>
    <el-table
        :data="data.filter(data => !search || data.username.toLowerCase().includes(search.toLowerCase()))"
        stripe
        max-height="450"
        :default-sort = "{prop: 'date', order: 'descending'}"
        border
        style="width: 100%">
      <el-table-column
          width="110"
          fixed
          sortable
          label="申请日期"
          prop="created">
      </el-table-column>
      <el-table-column
          fixed
          label="用户名"
          width="110"
          prop="username">
      </el-table-column>
      <el-table-column
          width="50"
          label="性别"
          prop="sex">
      </el-table-column>
      <el-table-column
          width="110"
          label="联系电话"
          prop="telephone">
      </el-table-column>
      <el-table-column
          width="150"
          label="邮箱"
          prop="email">
      </el-table-column>
      <el-table-column
          width="100"
          label="居住地"
          prop="city">
      </el-table-column>
      <el-table-column
          width="200"
          label="银行账户"
          prop="bankaccount">
      </el-table-column>
      <el-table-column
          fixed="right"
          label="操作">
        <template slot-scope="scope">
          <el-button
              v-if="!isAll"
              size="mini"
              type="danger"
              @click="changeRequest(scope.row)">通过</el-button>
          <el-button
              v-if="isAll"
              size="mini"
              type="danger"
              @click="changeRequest(scope.row)">禁用</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: "userTable",
  props: ['data', 'search', 'isAll'],
  methods: {
    changeRequest(val){
      this.$bus.$emit('changeUserPass', val)
    }
  },
}
</script>

<style scoped>

</style>